<%@ page import="com.oval.util.JspHelper" %>
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="com.oval.foundation.util.*" %>
<%@ page import="com.oval.foundation.engine.*" %>
<%@ page contentType = "text/html;charset=UTF-8" %>
<%
  String enid = request.getParameter("edit_enid");
  String cnid = request.getParameter("edit_cnid");
  String jpid = request.getParameter("edit_jpid");
  String module = request.getParameter("edit_module");
  String labelcode = request.getParameter("edit_labelcode");
  //String labelnamecn = OvalEncode.ISOToGBK(request.getParameter("edit_labelnamecn"));
  String labelnamecn = OvalEncode.convertEncode(request.getParameter("edit_labelnamecn"),"iso-8859-1","utf-8");
  String labelnameen = request.getParameter("edit_labelnameen");
  //String labelnamejp = request.getParameter("edit_labelnamejp");
  String labelnamejp = OvalEncode.convertEncode(request.getParameter("edit_labelnamejp"),"iso-8859-1","utf-8");
  
  // the following is added to help ps people editing labelname! 
  // by andyyang 2003/01/20
  boolean isForPageEdit = false;
  String readonly = "";
  if(module!=null && labelcode!=null && labelnamecn==null && labelnameen==null)
  {
    isForPageEdit = true;
    readonly = "readonly";
    OvalSearchAPI osa = new OvalSearchAPI();
    String whereclause = "";
    if(module.length() != 0)
      whereclause += " and module like '" + module + "'";
    if(labelcode.length() != 0)
      whereclause += " and labelcode like '" + labelcode + "'";
    whereclause += " order by labelcode asc";
    Vector labels = osa.getSearchResults("ovscreenlabel",whereclause,null,null);
    if(labels==null)
      labels = new Vector();
    if(labels.size()==3)
    {
      HashMap cnLabel=new HashMap();
      HashMap enLabel=new HashMap();
      HashMap jpLabel=new HashMap();
      for(int ii=0;ii<labels.size();ii++)
      {
        HashMap tempLabel=(HashMap)labels.get(ii);
        if((String)tempLabel.get("languagecode")!=null && ((String)tempLabel.get("languagecode")).equalsIgnoreCase("cn"))
          cnLabel = tempLabel;
        else if((String)tempLabel.get("languagecode")!=null && ((String)tempLabel.get("languagecode")).equalsIgnoreCase("en"))
          enLabel = tempLabel;
        else if((String)tempLabel.get("languagecode")!=null && ((String)tempLabel.get("languagecode")).equalsIgnoreCase("jp"))
        	jpLabel = tempLabel;
      }
      if(cnLabel!=null && enLabel!=null)
      {
        enid=((Integer)enLabel.get("labelid")).toString();
        cnid=((Integer)cnLabel.get("labelid")).toString();
        jpid=((Integer)jpLabel.get("labelid")).toString();
        labelnameen=(String)enLabel.get("labelname");
        labelnamecn=(String)cnLabel.get("labelname");
        labelnamejp=(String)jpLabel.get("labelname");
      }      
    }    
  }
%>
<html>
<head>
<title>e-manager</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../css/chinese/csscontent.css" type="text/css"> 
<script language="JavaScript" src="../css/chinese/script.js"></script>
<script language="JavaScript">

<%--what to do if press DONE Button--%> 

function page_done()
{
  frm.actionname.value = "edit";
  <%--[SCRIPT]  frm.edit_enid.value = "<#%= enid %#>";  [SCRIPT]--%>
  <%--[SCRIPT]  frm.edit_cnid.value = "<#%= cnid %#>";  [SCRIPT]--%>
  if(isEmpty(frm.module.value) || isEmpty(frm.labelcode.value) || isEmpty(frm.labelnamecn.value) || isEmpty(frm.labelnameen.value)|| isEmpty(frm.labelnamejp.value))
  {
    alert("Please input every data!");  
    return;
  }
<%if(isForPageEdit){%>
  frm.editforps.value="Y";
<%}%>
  document.frm.submit();
}

<%--Display The Page--%>  

</script>
</head>
<body>
<form name="frm" action="labelAction.jsp">
  <input type="hidden" name="actionname">
  <input type="hidden" name="edit_enid" value="<%=JspHelper.filterNull( enid )%>">
  <input type="hidden" name="edit_cnid" value="<%=JspHelper.filterNull( cnid )%>">
  <input type="hidden" name="edit_jpid" value="<%=JspHelper.filterNull( jpid )%>">
  <input type="hidden" name="editforps">
<table width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="#999999">
  <tr> 
    <td class="td_title_bg">
      Moudule Name
    </td>
    <td class="td_title_bg">
      Label Code
    </td>
    <td class="td_title_bg">
      Label Name(CN)
    </td>
     <td class="td_title_bg">
      Label Name(EN)
    </td>
    <td class="td_title_bg">
      Label Name(JP)
    </td>
  </tr>
     <tr class="td_bg_row"> 
       <td class="text">
         <div align="left">
           <input type="text" name="module" value="<%=JspHelper.filterNull( module )%>" <%=JspHelper.filterNull( readonly)%>>
         </div>
       </td>
       <td class="text">
         <div align="left">
           <input type="text" name="labelcode" value="<%=JspHelper.filterNull( labelcode )%>" <%=JspHelper.filterNull( readonly)%>>
         </div>
       </td>
       <td class="text">
         <div align="left">
           <input type="text" name="labelnamecn" value="<%=JspHelper.filterNull( labelnamecn )%>">
         </div>
       </td>
       <td class="text">
         <div align="left">
           <input type="text" name="labelnameen" value="<%=JspHelper.filterNull( labelnameen )%>">
         </div>
       </td>
       <td class="text">
         <div align="left">
           <input type="text" name="labelnamejp" value="<%=JspHelper.filterNull( labelnamejp )%>">
         </div>
       </td>
     </tr>
  <tr> 
    <td class="td_title_bg" colspan="10">
         <div align="center">
           <input type="button" name="DONE" value="DONE" onclick="javascript:page_done()">
           <%if(isForPageEdit){%>
           <input type="button" name="BACK" value="CANCEL" onclick="javascript:window.close();">
           <%}else{%>
           <input type="button" name="BACK" value="BACK" onclick="javascript:history.go(-1)">
           <%}%>
         </div>
    </td>
  </tr>
</table>
</form>
</body>
</html>

